//Matthew Caraway
//Stephen Zapp
//CS314 Homework Assignment 1

import java.io.*;

public class UI {


	
	public void user_interface_main(){
		String choice="";
		boolean validChoice = false;
		
		while (validChoice == false){
			System.out.println("Start-up (Main) interface");
			System.out.println("1. Airline System");
			System.out.println("2. Cruise System");
			System.out.println("3. Exit");
			System.out.println("Enter one of the numbers above: ");
		
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			try {
				choice = reader.readLine();
			} catch (IOException e) {
	            e.printStackTrace();
	        } 
			if ( !(choice.matches("[1|2|3]")) ) {
					
				
				System.out.println ("Bad input. Try again. Only the given integers are valid");
				
			}
			else { validChoice = true;}
			
		}
			
			if (choice == "1"){ user_interface_main_airline(); }
			if (choice == "2"){	user_interface_main_cruise(); }
			if (choice == "3"){	return; }
					
		
	}
	
	public void user_interface_main_airline(){
		String choice="";
		boolean validChoice = false;
		
		while (validChoice == false){
		System.out.println("Airline System interface");
		System.out.println("1. Admin Functions ");
		System.out.println("2. Find Available Seats ");
		System.out.println("3. Book Seat ");
		System.out.println("4. Return to Main");
		System.out.println("Enter one of the numbers above:");
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			choice = reader.readLine();
		} catch (IOException e) {
            e.printStackTrace();
        } 
		if ( !(choice.matches("[1|2|3|4]")) ) {
				
			
			System.out.println ("Bad input. Try again. Only the given integers are valid");
			
		}
		else { validChoice = true;}
		
	}
		
		if (choice == "1"){ user_interface_airline_admin(); }
		if (choice == "2"){	findSeats(); }
		if (choice == "3"){	bookSeat(); }
		if (choice == "4"){ user_interface_main(); }
		
	}
	
	public void user_interface_main_cruise(){
		String choice="";
		boolean validChoice = false;
		
		while (validChoice == false){
		System.out.println("Cruise System interface");
		System.out.println("1. Admin Functions ");
			user_interface_cruise_admin();
		System.out.println("2. Find Available Cabins ");
		System.out.println("3. Book Cabin ");
		System.out.println("4. Return to Main");
		System.out.println("Enter one of the numbers above:");
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			choice = reader.readLine();
		} catch (IOException e) {
            e.printStackTrace();
        } 
		if ( !(choice.matches("[1|2|3|4]")) ) {
				
			
			System.out.println ("Bad input. Try again. Only the given integers are valid");
			
		}
		else { validChoice = true;}
		
	}
		
		if (choice == "1"){ user_interface_cruise_admin(); }
		if (choice == "2"){	findCabins(); }
		if (choice == "3"){	bookCabin(); }
		if (choice == "4"){ user_interface_main(); }
	}
	
	public void user_interface_airline_admin(){
		
		String choice="";
		boolean validChoice = false;
		admin_login();
		
		while (validChoice == false){
		System.out.println("Airline Admin Functions Interface");
		System.out.println("1. Create an airport");
		System.out.println("2. Create an airline");
		System.out.println("3. Create a flight");
		System.out.println("4. Return to Airline Menu");
		System.out.println("Enter one of the numbers above: ");
		
		//choice = System.in.toString();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			choice = reader.readLine();
		} catch (IOException e) {
            e.printStackTrace();
        } 
		if ( !(choice.matches("[1|2|3|4]")) ) {
				
			
			System.out.println ("Bad input. Try again. Only the given integers are valid");
			
		}
		else { validChoice = true;}
		
		}
		
		if (choice == "1"){ createAirport(); }
		if (choice == "2"){	createAirline(); }
		if (choice == "3"){	createFlight(); }
		if (choice == "4"){	user_interface_main_airline(); }
		

	}
	
	public void user_interface_cruise_admin(){
		String choice="";
		boolean validChoice = false;
		admin_login();
		
		while (validChoice == false){
			System.out.println("Cruise Admin Functions Interface");
			System.out.println("1. Create cruise");
			System.out.println("2. Create a port");
			System.out.println("3. Create a trip");
			System.out.println("4. Return to Cruise Menu");
			System.out.println("Enter one of the numbers above:");
			
//			choice = System.in.toString();
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			try {
				choice = reader.readLine();
			} catch (IOException e) {
	            e.printStackTrace();
	        } 
			
			if ( !(choice.matches("[1|2|3|4]")) ) {
					
				
				System.out.println ("Bad input. Try again. Only the given integers are valid");
				
			}
			else { validChoice = true;}
			
		}
		
		
		
		if (choice == "1"){createCruise();}
		if (choice == "2"){createPort();}
		if (choice == "3"){createTrip();}
		if (choice == "4"){user_interface_main_cruise();}
		else {System.out.println("How did we get here?!");}
		
	
		
		
		

	}
	
	public void admin_login(){
		
		String userName="", pwd="";
		boolean isCorrectLogin = false;
		boolean isCorrectPWD = false;
		
		while (isCorrectLogin == false){
			System.out.print("Please enter the Administrator's username: ");
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			//userName = System.in.toString();
	        try {
	            userName = reader.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        } 
	        
			if (userName.equals("admin")){
				isCorrectLogin = true;
				
			}
			
			else{ System.out.println("Invalid Administrator login.");}
			
		}
		
		
		while (isCorrectPWD == false){
		System.out.println("Please enter the password for this Administrator: ");
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//pwd = System.in.toString();
        try {
            pwd = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        } 
        
			if(pwd.equals("admin123")){
			
				isCorrectPWD = true;
			}
		
			else{ System.out.println("Invalid password for the Administrator");}
		
		}
		
		
	}
	





	public void createCruise(){
		
		
	}
	public void createPort(){
		
		
	}
	public void createTrip(){
		
		
	}
	
	public void createAirport(){
		
	}
	
	public void createAirline(){
		
	}
	
	public void createFlight(){
		
	}
	
	public void bookSeat(){
		
		
	}
	
	public void findSeats(){
		
	
	}
	
	public void findCabins(){
		
	
	}
	
	public void bookCabin(){
		
	}

	
}//end class
